<?php
class Application_Model_DbTable_Tournament extends Zend_Db_Table_Abstract
{
    protected $_name = 'tournament';
	protected $_dependentTables = array('Application_Model_DbTable_Event');
    
	public function GetAllTournaments($visible = true){
    	$where = null;
    	if($visible){
    		$where = 'visible = 1';
    	}
    	$res = $this->fetchAll($where);
    	return $res->toArray();
    }
    
	public function GetTournamentById($id){
		$_id = (int)$id;
    	$select = $this->select();
    	if($id){
    		$select->where('id = ?', $_id);
    	}
    	$res = $this->fetchRow($select);
    	if(!$res){
    		throw new Zend_Db_Table_Exception('Cant find id ' . $_id, null);
    	}
    	return $res;
    }
}
